/*
    Copyright (C) 2012  Collombet

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    */

#ifndef DYNAMICARRAY_H
#define DYNAMICARRAY_H

#include <stdio.h>
#include <stdlib.h>

struct s_DynamicArray
{
    void** array;
    int count;
    int allocated;
} typedef DynamicArray;

/**
 * @brief dynamicArray_create
 * @param dynamicArray
 */
void dynamicArray_create(DynamicArray** dynamicArray);

/**
 * @brief dynamicArray_initialize
 * @param dynamicArray
 */
void dynamicArray_initialize(DynamicArray* dynamicArray);

/**
 * @brief dynamicArray_initializeCopy
 * @param dynamicArray
 * @param source
 */
void dynamicArray_initializeCopy(DynamicArray* dynamicArray, const DynamicArray* source);

/**
 * @brief dynamicArray_copy
 * @param dynamicArray
 * @param source
 */
void dynamicArray_copy(DynamicArray* dynamicArray, const DynamicArray* source);

/**
 * @brief dynamicArray_clear
 * @param dynamicArray
 */
void dynamicArray_clear(DynamicArray* dynamicArray);

/**
 * @brief dynamicArray_destroy
 * @param dynamicArray
 */
void dynamicArray_destroy(DynamicArray** dynamicArray);

/**
 * @brief dynamicArray_inserFirst
 * @param dynamicArray
 * @param value
 */
void dynamicArray_inserFirst(DynamicArray* dynamicArray, void* value);

/**
 * @brief dynamicArray_inserLast
 * @param dynamicArray
 * @param value
 */
void dynamicArray_inserLast(DynamicArray* dynamicArray, void* value);

/**
 * @brief dynamicArray_inserAt
 * @param dynamicArray
 * @param value
 * @param index
 * @return
 */
int dynamicArray_inserAt(DynamicArray* dynamicArray, void* value, int index);

/**
 * @brief dynamicArray_removeLast
 * @param dynamicArray
 */
void dynamicArray_removeLast(DynamicArray* dynamicArray);

/**
 * @brief dynamicArray_removeFirst
 * @param dynamicArray
 */
void dynamicArray_removeFirst(DynamicArray* dynamicArray);

/**
 * @brief dynamicArray_remove
 * @param dynamicArray
 */
int dynamicArray_remove(DynamicArray* dynamicArray, void *value);

/**
 * @brief dynamicArray_removeAt
 * @param dynamicArray
 * @param index
 * @return
 */
int dynamicArray_removeAt(DynamicArray* dynamicArray, const int index);

#endif /* DYNAMICARRAY_H*/
